package com.prj.ufdm.cloud.svr.gateway.bpo._impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.TypeReference;
import com.prj.ufdm.cloud.base.dto.RetData;
import com.prj.ufdm.cloud.svr.gateway.bpo.SysFunctionBPO;
import com.prj.ufdm.cloud.svr.gateway.constant.WebMsUrlConstants;
import com.prj.ufdm.cloud.svr.gateway.model.SysFunction;
import com.prj.ufdm.cloud.svr.gateway.util.RestTemplateUtil;

/**
 * 系统功能管理
 */
@Service 
public class SysFunctionBPOImpl  implements SysFunctionBPO {
	
	@Autowired
	RestTemplate restTemplate;
	
    /**
	 * 描述: 查询所有功能信息
	 * @auther 胡义振
	 * @param userId 用户ID
	 * @return 用户资源列表
	 * @throws Exception
	 */
    @Override
	public List<SysFunction> doGetFunctionList() throws Exception
	{
    	RestTemplateUtil restTemplateUtil = new RestTemplateUtil(restTemplate);
    	RetData<List<SysFunction>> retListSysFunction = restTemplateUtil.reqPostForm(WebMsUrlConstants.GET_FUNCTION_LIST_URL, null, null, new TypeReference<RetData<List<SysFunction>>>(){});
    	System.out.println("\n 初始化 retListSysFunction ："+retListSysFunction);
    	return retListSysFunction.getRetBody();
	}
    
    @Override
	public List<SysFunction> doGetFunctionListByUserId(String userId) throws Exception
	{
    	RestTemplateUtil restTemplateUtil = new RestTemplateUtil(restTemplate);
		Map<String,String> reqFormParamMap = new HashMap<String,String>();
		reqFormParamMap.put("userId",userId);
		RetData<List<SysFunction>> retListSysFunction = restTemplateUtil.reqPostForm(WebMsUrlConstants.GET_FUNCTION_LIST_BY_USER_ID_URL, null, reqFormParamMap, new TypeReference<RetData<List<SysFunction>>>(){});
		return retListSysFunction.getRetBody();
	}

	
}
